﻿namespace XQuery
{
    using System;
    using System.Linq;
    using System.Xml.Linq;

    public class Program
    {
        public static void Main()
        {
            // List all books by Serge and Peter with co-authored books repeated
            var document = XDocument.Load("bib.xml");
            var b1 = document
                .Descendants("book")
                .Where(b => b.Elements("author").Elements("first").Any(f => (string)f == "Serge"));
            var b2 = document
                .Descendants("book")
                .Where(b => b.Elements("author").Elements("first").Any(f => (string)f == "Peter"));
            var books = b1.Concat(b2);
            foreach (var q in books)
            {
                Console.WriteLine(q);
            }

            Console.ReadLine();
        }
    }
}